package top.xtcoder.jdcbase.test.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import top.xtcoder.jdcbase.base.knife4j.Knife4jPBApiInfo;
import top.xtcoder.jdcbase.base.knife4j.Knife4jPBGlobalRequestParam;

//@Configuration
public class Knife4jConfig {
    @Value("${knife4j.enable:false}")
    private boolean enable;
    @Autowired
    private Knife4jPBApiInfo apiInfo;
    @Autowired
    private Knife4jPBGlobalRequestParam global;

    @Bean(value = "default1")
    public Docket default1() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .enable(enable)
                .apiInfo(apiInfo.apiInfo())
                .groupName("测试分组")
                .select()
                .apis(RequestHandlerSelectors.basePackage("top.xtcoder.jdcbase.test.controller"))
                .paths(PathSelectors.any())
                .build()
                .globalOperationParameters(global.getGlobalRequestParameters());
        return docket;
    }
}
